﻿using MediatR;
using T.Basic.API.Appliction.Command.VehicleCommand;
using T.Basic.Repository.BasicImpl;
using T.Basic.Repository.BasicInterface;

namespace T.Basic.API.Appliction.CommandHandlers.VehicleHanders
{
    /// <summary>
    /// 单删车辆信息
    /// </summary>
    public class VehicleDeleteCommandHandler : IRequestHandler<VehicleDeleteCommand, int>
    {
        private readonly IVehicleRepository _vehicleRepository;
        public VehicleDeleteCommandHandler(IVehicleRepository vehicleRepository)
        {
            _vehicleRepository = vehicleRepository;
        }
        public async Task<int> Handle(VehicleDeleteCommand request, CancellationToken cancellationToken)
        {
            var sss = await _vehicleRepository.GetModelsAsync(request.VehicleId);
            sss.IsDeleted = true;
           
            return await _vehicleRepository.UpdateAsync(sss);
        }
    }
}
